#pragma once

#include <string>
#include <memory>
#include <vector>
#include <pthread.h>
#include "ZYUtils/ZYThread.h"  
#include "Player/MediaPlayer.h"
#include "Network/TcpServer.h"

namespace ZYLive {
    class LiveServer {
    public:
        explicit LiveServer(std::string dir);
        ~LiveServer();
        
        std::string getLiveUrl();
        void createMediaPlayer(std::string url, bool bIsRtmp = false);
        
    private:
        void startServer(std::string dir);
        // void start(std::string dir); 
        void generateURL(std::string url, bool bIsRtmp);
        

        void initZLMediaKit(const std::string& ini_file, const std::string& pem_file);
        void startServers();
        void setupSignalHandler();
        void stopServer();
        
    private:
        std::shared_ptr<ZYUtils::ZYThreadPool> mThreadPool;
        std::shared_ptr<std::shared_ptr<mediakit::MediaPlayer>> mPlayer;
        std::vector<std::shared_ptr<toolkit::TcpServer>> mServers; // 保存服务器实例
        
        std::string mUrl;
        std::string mIPAddr;
        pthread_t mThreadID = 0;
    };
}